﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////


#pragma once

#include "GnufBase.h"
#include "GnufAnnouncementInterface.h"

namespace gnuf {
    class Info;
    
    class GNUF_BASE_EXPORT IAnnouncementObserver : public gcmp::WeakReferenceable
    {
    public:
        virtual bool onButtonClicked(const std::string & key, int buttonIndex) = 0;
        // 关闭事件
        virtual void onClosed(const std::string & key) {};
    };
    
    class GNUF_BASE_EXPORT Announcement
    {
    public:
        virtual ~Announcement();

        AnnouncementType type() const { return m_type; }

        void setLevel(AnnouncementLevel);
        AnnouncementLevel level() const { return m_level; }
        
        void setInfo(const Info &);

        void setText(const std::wstring & val) { m_text = val; }
        const std::wstring & text() const { return m_text; }

        void setIconDir(const std::wstring & val) { m_iconDir = val; }
        const std::wstring & iconDir() const { return m_iconDir; }

    protected:
        explicit Announcement(AnnouncementType, AnnouncementLevel);
        Announcement(const Announcement &);

    private:
        const AnnouncementType m_type;
        AnnouncementLevel m_level;
        std::wstring m_text;
        std::wstring m_iconDir;
    };

    class GNUF_BASE_EXPORT LowDegreeAnnouncement : public Announcement
    {
    public:
        explicit LowDegreeAnnouncement(AnnouncementLevel level = AnnouncementLevel::eInfo);
        LowDegreeAnnouncement(const LowDegreeAnnouncement &);
        virtual ~LowDegreeAnnouncement();

        void setHasCloseButton(bool val) { m_hasCloseButton = val; }
        bool hasCloseButton() const { return m_hasCloseButton; }

    private:
        bool m_hasCloseButton;
    };
    
    class GNUF_BASE_EXPORT MediumDegreeAnnouncement : public Announcement
    {
    public:
        using Buttons = std::vector<std::wstring>;
        explicit MediumDegreeAnnouncement(
            const std::string & key, 
            const std::wstring& caption,
            const std::wstring& description,
            AnnouncementLevel level = AnnouncementLevel::eInfo,
            const MediumDegreeAnnouncement::Buttons & buttons = {});
        MediumDegreeAnnouncement(const MediumDegreeAnnouncement &);
        virtual ~MediumDegreeAnnouncement();
        
        ///\return Return the key.
        const std::string & key() const { return m_key; }

        const std::wstring& caption() const{ return m_caption; }

        const std::wstring& description() const{ return m_description; }
        
        ///\return Return the buttons;
        const MediumDegreeAnnouncement::Buttons & buttons() const { return m_buttons; }
        
    private:
        const std::string m_key;
        const std::wstring m_caption;
        const std::wstring m_description;
        const MediumDegreeAnnouncement::Buttons m_buttons;
    };
}
